package com.xh.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.print.attribute.ResolutionSyntax;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.xh.common.ObjectUtils;
import com.xh.common.StringConst;
import com.xh.common.StringUtils;
import com.xh.model.ProcedureTable;
import com.xh.service.IProcedureService;

import sun.security.action.GetBooleanAction;

@Controller
@RequestMapping("/procedure")
public class ProcedureAction {	
	@Autowired
	private  IProcedureService iProcedureService;	
	//以静态map保存存储过程列表key是编号code
	public static Map<String, ProcedureTable> procedureTable=new HashMap<String,ProcedureTable>();
	//public static List procedureTable=new ArrayList();	
	
	@ResponseBody
	@RequestMapping("/getValue")
	public JSONArray getValue(HttpServletRequest request) {	 
   //获取列表编号
	String code = request.getParameter("code");
	ProcedureTable pTable=  procedureTable.get(code);
	if(pTable==null){//如果根据编号找不到，更新procedureTable并重新查询
		procedureTable.clear();
		procedureTable=getAll();
	}
	iProcedureService.getValue(pTable);	
	Map<String, Object> dataMap = ObjectUtils.jsonToMapByLower(request.getParameter("data"));	
	return null;
	}
	
	public Map<String, ProcedureTable> getAll(){
		Map<String, ProcedureTable>  procedureTable=new HashMap<>();
		
		
		
		return procedureTable;
	}
	
	@ResponseBody
	@RequestMapping("/getJSON")
	public Map<String,Object> getJSON(@RequestBody String jsonStr){
		Map<String,Object> retMap = new HashMap<String,Object>();
		
		//判断数据是否为空
		if (StringUtils.isNull(jsonStr)) {
			retMap.put("retCode", StringConst.ERROR_CODE_002);
			retMap.put("message", "参数不能为空");
			return retMap;
		}
		
		
		
		return retMap;
	}
}
